<template>
  <div class="count-box" v-if="this.$store.state.count>=0">
	本月剩余<span style="color: #FF5555;">{{this.$store.state.count}}</span>次
  </div>
</template>

<script>
  export default{
    data() {
      return{
		count:0,
      }
    },
	created() {
		let key = localStorage.getItem("key");
		if(key){
			this.getUserCount()
		}
	},
    methods:{
		getUserCount(){
			let userInfo = JSON.parse(sessionStorage.getItem("info"));
			this.$ajax.get(`vipOrder/surplusCount?userId=${userInfo.userId}`).then(res=>{
				// this.count=res.data.data
				this.$store.commit('count', res.data.data)
			})
		}
    }
  }
</script>

<style lang="scss" scoped>
	.count-box{
		width: 100%;
		display: inline-flex;
		margin-left: 15px;
		line-height: 20px;
		margin-top: 10px;
		color: #999;
		font-size: 16px;
		display: flex;
		justify-content: center;
	}
	@media screen and (max-width:450px) {
		.count-box{
			margin-left: 0;
		}
	}
</style>
